package com.aspyn.tetris;

import android.graphics.Point;

public class GridManager {
	final int kGridWidth = 10;
	final int kGridHeight = 20;

	private int boxWidth;
	private int boxHeight;

	Point[][] grid;
	ShapeType[][] gridPosOccupied;//0 is not occupied, 1 is square, 2 is LLeft, 3 is LRight, 4 is S, 5 is Z, 6 is T, 7 is Stick

	public void setUpGrid(int screenW, int screenH) {
		
		//Creates grid
		grid = new Point[kGridHeight][kGridWidth];
		gridPosOccupied = new ShapeType[kGridHeight][kGridWidth];
		
		boxWidth = screenW/kGridWidth;
		boxHeight = screenH/kGridHeight;
		
		int x = boxWidth/2, y = boxHeight/2;
		for (int row = 0; row<kGridHeight; row++) {
			for (int column = 0; column < kGridWidth; column++) {
				grid[row][column] = new Point(x,y);
				gridPosOccupied[row][column] = ShapeType.NONE;
				x += boxWidth;
			}
			y += boxHeight;
			x = boxWidth/2;
		}
	}
	
	public void setGridPosOccupied(int x, int y, ShapeType value) {
		gridPosOccupied[x][y] = value;
	}
	
	public ShapeType getGridPosOccupied(int x, int y) {
		return gridPosOccupied[x][y];
	}
	
	public int getGridWidth() {
		return kGridWidth;
	}
	public int getGridHeight() {
		return kGridHeight;
	}
	
	public int getBoxWidth() {
		return boxWidth;
	}
	
	public int getBoxHeight() {
		return boxHeight;
	}
}
